import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import personInfor from "@/router/personInfor"; // 引入单独的路由配置文件
import bjBuilding from "@/router/bjBuilding";
import houseAdmin from "@/router/houseAdmin";
import housePropertyAnalysis from "@/router/housePropertyAnalysis";
import enterpriseCreditAnalysis from "@/router/enterpriseCreditAnalysis";
import projectMonitoringAnalysis from "@/router/projectMonitoringAnalysis";
import landComprehensiveAnalysis from "@/router/landComprehensiveAnalysis";
import housingSafetyManagementMonitoringAnalysis from "@/router/housingSafetyManagementMonitoringAnalysis";
import realEstate from "@/router/realEstate";
import housePropertyTradeAnalysis from '@/router/housePropertyTradeAnalysis';
import eachAdmin from "@/router/eachAdmin";
import propertyLife from "@/router/propertyLife";
import housePropertyAnalysisAndForecast from "@/router/housePropertyAnalysisAndForecast";
import houseDetecAnalysis from "@/router/houseDetecAnalysis";
import fundAdminDataConverge from "@/router/fundAdminDataConverge";
import landSupply from "@/router/landSupply";
import housePropertyDevelopmentConstruction from "@/router/housePropertyDevelopmentConstruction"; // 开发建设
import housePropertyCommodityHouseSupply from "@/router/housePropertyCommodityHouseSupply"; // 商品房供应
import guaranteeDeliveryHouseCondition from "@/router/guaranteeDeliveryHouseCondition"; // 保交房情况
import stoppedSuspendedProjectVitalizeCondition from "@/router/stoppedSuspendedProjectVitalizeCondition"; // 停缓建项目盘活情况
import newCommodityHouseDemandForecast from "@/router/newCommodityHouseDemandForecast"; // 新建商品房需求预测

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "Home",
    component: () => import("@/views/Home.vue"),
    meta: {
      title: "辽宁房产数据大屏-首页",
    },
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/Login.vue"),
    meta: {
      title: "辽宁房产数据大屏-登录",
    },
  },
  ...personInfor,
  ...bjBuilding,
  ...houseAdmin,
  ...housePropertyAnalysis,
  ...realEstate,
  ...housePropertyTradeAnalysis,
  ...eachAdmin,
  ...enterpriseCreditAnalysis,
  ...projectMonitoringAnalysis,
  ...propertyLife,
  ...landComprehensiveAnalysis,
  ...housingSafetyManagementMonitoringAnalysis,
  ...housePropertyAnalysisAndForecast,
  ...houseDetecAnalysis,
  ...fundAdminDataConverge,
  ...landSupply,
  ...housePropertyDevelopmentConstruction,
  ...housePropertyCommodityHouseSupply,
  ...guaranteeDeliveryHouseCondition,
  ...stoppedSuspendedProjectVitalizeCondition,
  ...newCommodityHouseDemandForecast,
];
const router = createRouter({
  history: createWebHistory(),
  routes,
});

// 路由守卫
// router.beforeEach((to, from, next) => {
//   const isLogin: Boolean = localStorage.getItem("token") ? true : false;
//   if (to.path === "/login") {
//     next();
//   } else {
//     isLogin ? next() : next("/login");
//   }
// });

// router.afterEach((to: any) => {
//   document.title = to.meta?.title || "Default Title";
// });

export default router;
